home *** CD-ROM | disk | FTP | other *** search
/ Champak 54 / Vol 54.iso / games / turttleo.swf / scripts / DefineSprite_85_game_scr / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2007-10-01  |  690 b   |  30 lines

  1. function onKey(e)
  2. {
  3.    switch(e.code)
  4.    {
  5.       case 37:
  6.          xspeed = -1 * e.what;
  7.          break;
  8.       case 39:
  9.          xspeed = 1 * e.what;
  10.          break;
  11.       case 32:
  12.          _root.main.game.jump_char();
  13.    }
  14. }
  15. var kd = [{state:false,code:39},{state:false,code:37},{state:false,code:32}];
  16. mx.events.EventDispatcher.initialize(kd);
  17. kd.addEventListener("key",onKey);
  18. setInterval(function()
  19. {
  20.    for(var _loc4_ in kd)
  21.    {
  22.       if(kd[_loc4_].state != Key.isDown(kd[_loc4_].code))
  23.       {
  24.          kd.dispatchEvent({type:"key",what:!kd[_loc4_].state,code:kd[_loc4_].code});
  25.       }
  26.       kd[_loc4_].state = Key.isDown(kd[_loc4_].code);
  27.    }
  28. }
  29. ,10);
  30.